package com.zxt.content.copywriting.service.impl;

import com.zxt.content.copywriting.req.CopywritingApiDTO;
import com.zxt.lock.annotation.DistributedLock;
import com.zxt.redis.annotation.CustomCache;
import com.zxt.utils.ZXTBeanUtils;
import com.zxt.content.copywriting.manager.PublicCopywritingManager;
import com.zxt.content.copywriting.resp.PublicCopywritingVO;
import com.zxt.content.copywriting.service.IPublicCopywritingService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 公共文案模块业务逻辑层
 *
 * @author zxt
 */
@Service(value = "publicCopywritingService")
@AllArgsConstructor
@Slf4j
public class PublicCopywritingServiceImpl implements IPublicCopywritingService {

    private PublicCopywritingManager publicCopywritingManager;

    @Override
    @DistributedLock(value = "queryCopywritingList")
    //@CustomCache
    public List<PublicCopywritingVO> queryList() {
        return ZXTBeanUtils.beanCopy(publicCopywritingManager.list(), PublicCopywritingVO.class);
    }

    @Override
    @CustomCache
    public PublicCopywritingVO query(CopywritingApiDTO dto) {
        PublicCopywritingVO vo = new PublicCopywritingVO();
        vo.setId(19L);
        vo.setAuthor("zxt");
        vo.setContent("保持热爱，奔赴山海");
        return vo;
    }

    @Override
    @CustomCache
    public Map<String, PublicCopywritingVO> queryMap() {
        Map<String, PublicCopywritingVO> map = new HashMap<>();
        PublicCopywritingVO vo = new PublicCopywritingVO();
        vo.setId(19L);
        vo.setAuthor("zxt");
        vo.setContent("保持热爱，奔赴山海");
        map.put("str", vo);
        return map;
    }
}
